import { ActiveBaseIcon } from "../activity/icon/ActiveBaseIcon";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { SecTimerView } from "../common/SecTimerView";
import { BossFieldEntranceWindow } from "./BossFieldEntranceWindow";
import { EffectManager } from "../../manager/EffectManager";
import { ClockManager } from "../../manager/ClockManager";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
//class BossfieldIconView
    
    export  class BossfieldIconView extends ActiveBaseIcon
    {
        constructor()
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */createChildren(): void
        {
            var loc1=null;
            this._spEnterBtnContainer = new Object /* flash.display.Sprite */();
            this._spEnterBtnContainer.mouseEnabled = false;
            this.addChild(this._spEnterBtnContainer);
            this._btnShowBFTips = ObjCreate.createGLoadedButton(ResFileConst.Battlefield, 0, 0, 50, 50, this._spEnterBtnContainer);
            loc1 = new GTextFormat(FontUtil.songtiName, 12, 16711680);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._secTimeView = new SecTimerView();
            this._secTimeView.mouseEnabled = false;
            this._secTimeView.setParse("mm: ss");
            this._secTimeView.defaultTextFormat = loc1;
            this._secTimeView.timeOutHandler = this.hideTimeView;
            ObjCreate.setObjAttri(this._secTimeView, 0, 47, 48, 20);
            return;
        }

        /* internal  */addListeners(): void
        {
            this._btnShowBFTips.addEventListener(flash.events.MouseEvent.CLICK, this.onClickShowBFTips);
            return;
        }

        /* internal  */onClickShowBFTips(arg1: Object /* flash.events.MouseEvent */): void
        {
            BossFieldEntranceWindow.instance.show();
            return;
        }

        public showLightMask(): void
        {
            if (!this._lightMask) 
            {
                this._lightMask = EffectManager.getLightMask(55, 55);
                this._lightMask.x = 2;
                this._lightMask.y = 2;
                this._btnShowBFTips.addChild(this._lightMask);
            }
            return;
        }

        public hideLightMask(): void
        {
            if (this._lightMask) 
            {
                EffectManager.disposeLightMask(this._lightMask);
                this._lightMask = null;
            }
            return;
        }

        public startCountdownLimitEnter(arg1: Date): void
        {
            this._spEnterBtnContainer.addChild(this._secTimeView);
            var loc1=new Date(arg1.time - ClockManager.instance.nowDate.time);
            var loc2=Math.ceil(loc1.time / 1000);
            this._secTimeView.setLeftTime(loc2);
            return;
        }

        /* internal  */hideTimeView(): void
        {
            if (this._secTimeView.parent) 
            {
                this._secTimeView.parent.removeChild(this._secTimeView);
            }
            return;
        }

        public stopLimitEnterCountDown(): void
        {
            this._secTimeView.stop();
            return;
        }

        /* internal */ /* var */_spEnterBtnContainer: Object /* flash.display.Sprite */;

        /* internal */ /* var */_btnShowBFTips: GLoadedButton;

        /* internal */ /* var */_secTimeView: SecTimerView;

        /* internal */ /* var */_lightMask: LightMask;
    }
